#include <stdio.h>
#include <unistd.h>

int main()
{
    int cnt = 0;
    while(1)
    {
        int id = fork();
        if(id < 0)
        {
            printf("fork fail! cnt:%d\n", cnt);
            break;
        }
        else if(id == 0)
        {
            // child
            while(1) sleep(1);
        }
        // parent
        ++cnt;
    }
}
